package cn.edu.dao;

import cn.edu.pojo.Order;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author wans
 * @create 2022-10-14 20:14
 */
public interface OrderMapper {
    @Select("select * from tb_orders where user_id=#{id} ")
    @Results({
            @Result(id = true,column = "id",property = "id"),
            @Result(column = "number",property = "number")
    })
    List<Order> selectOrdersByUserId(int user_id);
    //根据订单id查询订单，订单有关联的商品列表信息
    @Select("select * from tb_orders where id=#{id} ")
    @Results({@Result(id = true,column = "id",property = "id"),
            @Result(column = "number",property = "number"),
            @Result(column = "id",property = "productList",
                    many = @Many(select = "cn.edu.dao.ProductMapper.selectProductByOrdersId"))})
    Order selectOrdersById(int id);

}
